import count from '@dfeidao/atom-nodejs/db/count';
import query from "@dfeidao/atom-nodejs/db/query";
import log from '@dfeidao/atom-nodejs/logger/log';
import { systemid } from '../../atom/config';
interface Message {
	high_company_name: string;
	page_no: number;
}
interface v {
	v: string;
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	log(`Service begin`);
	// todo

	const { prepare, exec } = query(action_id, session_id, systemid);
	prepare('enterprise', ['company_no', 'high_company_name', 'corporate'], { high_company_name: msg.high_company_name }, 5, msg.page_no, [], []);

	const { prepare: p, exec: e } = count(action_id, session_id, systemid);
	p('enterprise', { high_company_name: msg.high_company_name });

	const [res] = await exec();
	res.forEach((v: v) => {
		v.v = JSON.stringify(v);
	});
	const [t] = await e();

	log(`Service end`);
	return { res, t };
}
